//package com.hilin.hilinim.netty.ws.amqp;
//
//import com.hilin.common.util.IpUtils;
//import org.springframework.amqp.core.*;
//import org.springframework.amqp.rabbit.connection.ConnectionFactory;
//import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//@Configuration
//public class AmqpConfig {
//    public static final String QUEUE_IM_NAME = "com.hilin.im.%s.%s",
//            EX_NAME = "com.hilin.message";
//
//    @Value("${server.port}")
//    private int port;
//
//    @Bean
//    public Queue imQueue() {
//        return new Queue(String.format(QUEUE_IM_NAME, IpUtils.getLocalIp(), port));
//    }
//
//    @Bean
//    public FanoutExchange pushDirectExchange() {
//        return new FanoutExchange(EX_NAME);
//    }
//
//    @Bean
//    public Binding pushBindingMail() {
//        return BindingBuilder.bind(imQueue()).to(pushDirectExchange());
//    }
//
//    @Bean
//    public SimpleMessageListenerContainer simpleMessageListenerContainer(ConnectionFactory connectionFactory, MQReceive listener) {
//        SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory);
//        container.addQueues(imQueue());
//        container.setExposeListenerChannel(true);
//        container.setMaxConcurrentConsumers(20);
//        container.setConcurrentConsumers(2);
//        container.setAcknowledgeMode(AcknowledgeMode.AUTO);
//        container.setMessageListener(listener);
//        return container;
//    }
//}
